

function setHotels(city,hotel) {
	var xmlhttp;
	if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp = new XMLHttpRequest();
	} else {// code for IE6, IE5
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			//my part:
			
			
			document.getElementById(hotel).innerHTML = ''; 		//get the hotels dropdown list
			var str=xmlhttp.responseText;						//get the response fron the service if 
																//form of a string like the following
																//[bla,bla]
			str = str.substring(1, str.length - 1);				//trim the list to bla,bla
			var list = str.split(',');							//split into js list
			var index;
			for (index = 0; index < list.length; ++index) {
				createOption(list[index],hotel);				//add every element of the list to 
																//the hotel dropdown
			}
			
		}
	}
	
	
	xmlhttp.open("GET", "ajax?city="+city.options[city.selectedIndex].text, true);
	xmlhttp.send();
}

//function to create "option" in a select field (item for the dropdown)
function createOption(value,dropdownlist) {
    el = document.createElement('option');
    el.value = value;
    el.innerHTML = value;
    el.id = value;

    document.getElementById(dropdownlist).appendChild(el);
}
